package com.longe.esaypoi.exportexcel;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.longe.entity.ExportUser;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class FirstSimpleDemo {

    public static void main(String[] args) throws Exception {

        List<ExportUser> list = new ArrayList<>();
        list.add(new ExportUser("jack", 20, "beijing", new Date(), 1));
        list.add(new ExportUser("tom", 23, "shanghai", new Date(), 2));

        ExportParams exportParams = new ExportParams("测试导出", "firstSheet", ExcelType.XSSF);
        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ExportUser.class, list);

        FileOutputStream fos = new FileOutputStream("D:\\TEST_EASY_POI\\EXPORT\\testExport.xlsx");
        workbook.write(fos);
        fos.close();
    }
}
